Repository navigation
Conversation
The mysql_database provider's self.instances rescued a missing
database by matching the English string "Unknown database" in the
error message from the mysql/mariadb client. Under a non-English
server/client locale (e.g. German, which reports "Unbekannte
Datenbank"), that match fails and the exception is re-raised,
breaking prefetch for every mysql_database resource in the catalog.
This surfaced via mysql::server::account_security, which declares
`mysql_database { 'test': ensure => absent }`: once the database is
removed on a first run, every subsequent run fails during prefetch
under a non-English locale.
Match on the numeric, locale-independent MySQL/MariaDB error code
1049 (ER_BAD_DB_ERROR) instead.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Use String#include? instead of a regex match with a literal-only pattern, per CI's RuboCop configuration. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
jst-cyr
marked this pull request as ready for review
November 10, 2026 12:51
jst-cyr
requested review from
a team,
alexjfisher and
bastelfreak
as code owners
November 10, 2026 12:51
Member
Author
|
✅ Acceptance Test Results: https://github.com/puppetlabs/puppetlabs-mysql/actions/runs/42744772141?pr=1769 Green across the board, good for review. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1761.
mysql_database'sself.instancesrescues a missing database during prefetch by checking whether the mysql/mariadb client's error message contains the English string"Unknown database". When the server/client reports errors in another locale (the reporter saw this on RHEL 9 with MariaDB 11.4 under a German locale, which prints"Unbekannte Datenbank"), that string match fails, the exception is re-raised, and prefetch fails for everymysql_databaseresource in the catalog — not just the missing one.This is especially easy to hit via
mysql::server::account_security, which declares:The first run removes the
testdatabase as desired. Every run after that fails during prefetch, because the database is now legitimately absent and the client raisesERROR 1049 (42000): Unbekannte Datenbank 'test'(or the equivalent in whatever locale the DB is configured for), which the old check didn't recognize.Fix
Match on the numeric MySQL/MariaDB error code
1049(ER_BAD_DB_ERROR) instead of the localized message text, since the code is stable across locales while the message text is not.Test plan
ERROR 1049 (42000): Unbekannte Datenbank 'managed_missing') and confirming it's now handled the same as the English-locale case.spec/unit/puppet/provider/mysql_database/mysql_spec.rbsuite passes (17 examples, 0 failures).